﻿<Window x:Class="ScrumFactory.Windows.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        
        xmlns:SF_Comp="clr-namespace:ScrumFactory.Composition;assembly=ScrumFactory.Composition"                             
        xmlns:SF_Ext="clr-namespace:ScrumFactory.Windows.Helpers.Extensions;assembly=ScrumFactory.Windows.Helpers"                    
        xmlns:SF="clr-namespace:ScrumFactory.Composition;assembly=ScrumFactory.Composition"                             
        xmlns:SF_Windows="clr-namespace:ScrumFactory.Windows"
        xmlns:SF_Helpers="clr-namespace:ScrumFactory.Windows.Helpers;assembly=ScrumFactory.Windows.Helpers"
        
        xmlns:props="clr-namespace:ScrumFactory.Windows.Properties"
        
        SnapsToDevicePixels="True"               
        UseLayoutRounding="True"
        
        
        x:Name="mainWindow"
        
  
        ResizeMode="CanMinimize" 
        WindowStartupLocation="Manual"
                
        Style="{StaticResource FactoryMainWindow}"
              
        Title="{Binding WindowTitle}" 
        
        TextElement.Foreground="{StaticResource LabelBrush}"
        TextElement.FontSize="{StaticResource BigFontSize}"
            
        Icon="/Images/factory.ico"
        
        mc:Ignorable="d"         
        d:DesignHeight="314"
        d:DesignWidth="452">
    <Window.InputBindings>
        <KeyBinding Key="F5" Command="{Binding RefreshCommand}" />
        <KeyBinding Key="F2" Command="{Binding ShowMyTasksCommand}"/>
    </Window.InputBindings>
    


    <Grid>
   

        <Grid x:Name="mainGrid" VerticalAlignment="Stretch">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"  />               
            </Grid.RowDefinitions>

            <SF_Windows:AlertMessage x:Name="alertMessage"
                                 Grid.Row="0" Margin="0"                                                                   
                                 DataContext="{Binding AlertMessageViewModel}" VerticalAlignment="Bottom"/>
           

            <!-- TOP MENU -->
            <Border x:Name="leftPanelsBorder"
                CornerRadius="0,0,0,0" Margin="0" BorderThickness="0" 
                Grid.Row="1" VerticalAlignment="Stretch" Padding="0"                
                Background="{StaticResource DockPanelStripBackground}">
                <TabControl     
                    x:Name="leftPanels" 
                    TabStripPlacement="Top" Margin="0" Padding="0"   
                    SelectedItem="{Binding SelectedTopMenuItem}"
                    ItemsSource="{Binding TopMenuItems}"
                    Style="{StaticResource DockPanelTabControl}"
                    VerticalAlignment="Stretch"/>
            </Border>


            
            
            <!-- SIGN IN MENU-->
            <Menu 
             Grid.Row="1" 
            Margin="0,0,0,0" HorizontalAlignment="Right" VerticalAlignment="Top">
                <MenuItem Header="{Binding SigninMenuText}" Command="{Binding SignInCommand}" Height="40" >
                    <MenuItem.Items>
                        <MenuItem Header="{x:Static props:Resources.Sign_out}" Command="{Binding SignInCommand}"/>
                        <MenuItem Header="{x:Static props:Resources.Close}" Command="{Binding CloseWindowCommand}"/>
                    </MenuItem.Items>
                    <MenuItem.Style>
                        <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsMemberSigned}" Value="true">
                                    <Setter Property="MenuItem.Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </MenuItem.Style>
                </MenuItem>
                <MenuItem Margin="0,0,0,0" Header="{Binding SignedMemberName}">
                    <MenuItem.Icon>
                        <ContentControl Style="{StaticResource MemberImageNoIndicatorControlStyle}" DataContext="{Binding SignedMember.MemberUId}"
                                        Width="38" Height="38"/>
                        <!--<Image 
                                 SF_Ext:ImageAsyncHelper.SourceUri="{Binding SignedMember.MemberUId, Converter={StaticResource MemberAvatarUrlConverter}}"                                
                                 Width="40" Height="40"/>-->
                    </MenuItem.Icon>
                    <MenuItem.Items>
                        <MenuItem Header="{x:Static props:Resources.My_profile}" Command="{Binding ShowMyProfileCommand}"/>
                        <MenuItem Header="{x:Static props:Resources.Sign_out}" Command="{Binding SignInCommand}"/>
                        <MenuItem Header="{x:Static props:Resources.Options_}" Command="{Binding ShowOptionsCommand}"/>                        
                        <MenuItem Header="{x:Static props:Resources.What_is_new}" Command="{Binding ShowWhatIsNewCommand}"/>
                        <MenuItem Header="{x:Static props:Resources.About}" Command="{Binding ShowAboutDialogCommand}"/>
                        <MenuItem Header="{x:Static props:Resources.Factory_owners}" Command="{Binding ShowOwnersListCommand}"  Foreground="{StaticResource TopMenuEspecialBrush}" />
                        <!--<MenuItem Header="{x:Static props:Resources.Factory_settings}" Command="{Binding ShowFactorySettingsCommand}"  Foreground="{StaticResource TopMenuEspecialBrush}"/>-->
                        <MenuItem Header="{x:Static props:Resources.Close}" Command="{Binding CloseWindowCommand}"/>
                    </MenuItem.Items>
                    <MenuItem.Style>
                        <Style  TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsMemberSigned}" Value="false">
                                    <Setter Property="MenuItem.Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </MenuItem.Style>
                </MenuItem>

                <Menu.Style>
                    <Style TargetType="Menu" BasedOn="{StaticResource {x:Type Menu}}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ElementName=leftPanels, Path=IsEnabled}" Value="False">
                                <Setter Property="Menu.Visibility" Value="Collapsed"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Menu.Style>
            </Menu>

            <!-- SIGNING TEXT -->
            <StackPanel Grid.RowSpan="2"
                  HorizontalAlignment="Center" VerticalAlignment="Center">
                 <TextBlock  Grid.RowSpan="2"
                    HorizontalAlignment="Center" VerticalAlignment="Center"
                    FontSize="40" Opacity="0.5" Foreground="{StaticResource MainTitleTextBrush}"
                    Text="{Binding SigninMenuText}">
            <TextBlock.Style>
                <Style>
                    <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding IsSigning}" Value="True">
                            <Setter Property="TextBlock.Visibility" Value="Visible"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </TextBlock.Style>

            </TextBlock>
                
            </StackPanel>
            
           

            <!-- SHOW HIDE MENU -->
            <Border   
                Grid.Row="1"
                Background="#444444" CornerRadius="0,0,4,4" Margin="0,40,0,0"
                VerticalAlignment="Top" HorizontalAlignment="Center" Cursor="Hand" Width="200" Height="5"
                IsVisibleChanged="Border_IsVisibleChanged"
                SF_Comp:CommandBehavior.RoutedEventName="MouseDown"
                SF_Comp:CommandBehavior.TheCommandToRun="{Binding ShowHideTopMenuCommand}">
                <Border.Triggers>
                    <EventTrigger  RoutedEvent="Border.MouseEnter">
                        <BeginStoryboard>
                            <Storyboard >
                                <DoubleAnimation Duration="00:00:0.3" Storyboard.TargetProperty="Height" From="5" To="10"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                    <EventTrigger  RoutedEvent="Border.MouseLeave">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Duration="00:00:0.3" Storyboard.TargetProperty="Height" From="10" To="5"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Border.Triggers>
                <Border.Style>
                    <Style TargetType="Border">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ShowTopMenu}" Value="True">
                                <Setter Property="Visibility" Value="Collapsed"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Border.Style>

            </Border>

            <!-- DARK SCREEN -->
            <Border Background="Black"  Grid.RowSpan="2" Opacity="0.8">
                <Border.Style>
                    <Style>
                        <Setter Property="Border.Visibility" Value="Collapsed"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ElementName=mainWindow, Path=IsActive}" Value="False">
                                <Setter Property="Border.Visibility" Value="Visible"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Border.Style>
            </Border>

            <!-- TASK LIST -->
            <StackPanel x:Name="taskPanel" Grid.Row="2">
                <Button x:Name="taskButton" Style="{StaticResource ShowTaskButton}" 
                        Command="{Binding ShowMyTasksCommand}"/>
                <ContentPresenter 
                    x:Name="taskList" 
                    Content="{Binding TaskSelector.View}" >
                    <ContentPresenter.Style>
                        <Style TargetType="ContentPresenter">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsTaskListVisible}" Value="False">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </ContentPresenter.Style>
                </ContentPresenter>
            </StackPanel>
           

        </Grid>

        <!--<StackPanel  VerticalAlignment="Top" HorizontalAlignment="Right" Orientation="Horizontal" Margin="0,12,10,0">
            <Button Style="{StaticResource MinimizeButton}" Command="{Binding MinimizeWindowCommand}"/>
            <Button Style="{StaticResource CloseButton}" Command="{Binding CloseWindowCommand}" Margin="6,0,0,0"/>
            <StackPanel.Style>
                <Style>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ShowTopMenu}" Value="True">
                            <Setter Property="StackPanel.Visibility" Value="Collapsed"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding IsOnTaskMode}" Value="True">
                            <Setter Property="StackPanel.Visibility" Value="Collapsed"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </StackPanel.Style>
        </StackPanel>-->

        <!--<Image Source="{Binding ImageLogoUrl}" Width="0" Height="0"/>-->
      
    </Grid>



       



</Window>
 